"""
-------------------------------
- File_Name: roles.py
- Date: 2025/2/23
- Author: yangzhide
- Email: xxzjyzd@126.com
- Description: 角色模型
-------------------------------
"""

from pydantic import BaseModel, Field
from app.models.utils import StatusType
from app.utils.common import to_camel_case


class SystemRoleBase(BaseModel):
    """系统管理-角色列表"""

    """角色编号"""
    role_code: str | None = Field(None)
    """角色名称"""
    role_name: str | None = Field(None)
    """角色默认首页"""
    role_home: str | None = Field("home")
    """角色描述"""
    role_desc: str | None = Field("这个人很懒，什么意没留下")
    """角色状态"""
    status: str | None = StatusType.enable


class SystemRoleCreate(SystemRoleBase):
    """系统管理-角色创建"""

    """创建者"""
    create_by: str | None = ""

    class Config:
        alias_generator = to_camel_case
        populate_by_name = True


class SystemRoleUpdate(SystemRoleBase):
    """系统管理-角色基础信息更新"""

    """更新者"""
    update_by: str | None = None

    class Config:
        alias_generator = to_camel_case
        populate_by_name = True

class SystemRoleMenuIdsUpdate(BaseModel):
    """系统管理-角色菜单id列表更新"""
    """菜单ids"""
    home: str | None = None
    menu_ids: list[str|int] = Field(None, alias="menuIds")
    """按钮codes"""
    menu_buttons: list[str] = Field(None, alias="menuButtons")


class SystemRoleOut(SystemRoleBase):
    """系统管理-返回角色列表"""
    id: int
    create_time: str
    create_by: str
    update_time: str | None = Field(None)
    update_by: str | None = Field(None)

    class Config:
        alias_generator = to_camel_case
        populate_by_name = True

class SystemAllRoleOut(BaseModel):
    """系统管理-返回所有角色列表"""
    id: int
    role_name: str = Field(serialization_alias="roleName")
    role_code: str = Field(serialization_alias="roleCode")